home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / LOGGING.TXT < prev    next >
Encoding:
Text File  |  2000-06-30  |  3.3 KB  |  105 lines

  1. Zope Logging
  2.  
  3.  Zope2 now comes with a Logging facility called ZLogger.  ZLogger is
  4.  an extensible logging system.  Currently, ZLogger will log either to a 
  5.  file or to syslog.  (Syslog logging works even on windows, because
  6.  it talks directly to the syslog server using UDP, instead of the
  7.  POSIX syslog calls).
  8.  
  9.  Logging is controlled by setting environment variables.  This is done
  10.  most easily by providing the settings on the z2.py command line.  For
  11.  example::
  12.  
  13.   $ python1.5.2 z2.py ZSYSLOG_SERVER="syslog.mydomain.com:514" \
  14.      STUPID_LOG_FILE=var/Zope.log"
  15.  
  16.  Currently, the following environment variables can be set:
  17.  
  18.   STUPID_LOG_FILE="path"
  19.  
  20.    The stupid file logger writes Zope logging information to a file.
  21.    It is not very smart about it - it just dumps it to a file and the
  22.    format is not very configurable - hence the name.
  23.  
  24.   ZSYSLOG="anything"
  25.  
  26.    Setting this environment variable will cause Zope to try and write
  27.    to the '/dev/log' UNIX domain socket.  This will only work on UNIX, 
  28.    and only if your syslogd domain socket is named /dev/log.
  29.  
  30.   ZSYSLOG_SERVER="machine.name:port"
  31.  
  32.    Setting this environment variable tells Zope to connect a UDP
  33.    socket to machine.name (which can be a name or IP address) and
  34.    'port' which must be an integer.  The default syslogd port is '514' 
  35.    but Zope does not pick a sane default, you must specify a port.
  36.    This may change, so check back here in future Zope releases.
  37.  
  38. Calling the logger in your code
  39.  
  40.  If you want your own Zope extensions to use logging:
  41.  
  42.   import zLOG
  43.   zLOG.LOG(subsystem, severity, summary, detail, error, reraise)
  44.  
  45.  The following arguments are required:
  46.  
  47.       subsystem -- The subsystem generating the message (e.g. ZODB)
  48.  
  49.       severity -- The "severity" of the event.  This may be an integer or
  50.                   a floating point number.  Logging back ends may
  51.                   consider the int() of this value to be significant.
  52.                   For example, a backend may consider any severity
  53.                   with integer value of WARNING to be a warning.  By
  54.                   default, the zLOG module defines the following
  55.                   severities:
  56.  
  57.             BLATHER=-100
  58.             INFO=0      
  59.             PROBLEM=WARNING=100             
  60.             ERROR=200   
  61.             PANIC=300
  62.  
  63.       summary -- A short summary of the event.
  64.  
  65.       detail -- A detailed description.
  66.  
  67.       error -- A three-element tuple consisting of an error type, value, and
  68.                traceback.  If provided, then a summary of the error
  69.                is added to the detail.
  70.  
  71.       reraise -- If provided with a true value, then the error given by
  72.                  error is reraised.
  73.   
  74.  
  75. Creating your own Logger
  76.  
  77.  Creating your own Zope logger is easy.  Simply define a logger class 
  78.  with the following interface::
  79.  
  80.   class LumberJack:
  81.       """ an ok Logger
  82.  
  83.       I sleep all night, I work all day
  84.       """
  85.  
  86.       def __init__(self):
  87.       pass
  88.  
  89.       def __call__(self, sub, sev, sum, det, err):
  90.       print ' %s, %s, %s, %s, %s, %s' % (self, sub, sev, sum, det, err)
  91.  
  92.  
  93. Then you must edit lib/python/Zope/ZLogger/ZLogger.py and instantiate
  94. one of your Loggers in the 'logger' tuple::
  95.  
  96.  loggers = (stupidFileLogger.stupidFileLogger(), 
  97.             syslogLogger.syslogLogger(),
  98.             LumberJack.LumberJack(),)
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.